When you print a log in a Linux/C + + program, you may need to print an unknown number of variable parameters, so the vsnprintf function comes in handy. A simple C-program example is used to illustrate the use of the vsnprintf function to print an
Variable-length parameters in C language are rarely used in self-designed interfaces during development. However, printf is the most commonly used parameter interface, while feeling the strong charm of printf, do you want to figure out how printf is
vsprintf
/* Function Name: vsprintf function: Send formatted output to string return value: Normally returns the length of the generated string (minus/0), and error conditions return negative usage: int vsprintf (char *string, Char *format,
Function types:
There are many string output functions, as shown in the following table:
ASCII
Wide text
General
Number of parameters
Standard Edition
Sprintf
Swprintf
_ Stprintf
Most buffer overflow problems in C can be traced directly to the standard C library. The worst culprits are problematic string operations (strcpy, Strcat, sprintf, and get) that do not perform self-variable checks. In general, strict rules such as
# Include
Stdio. h
>
# Include
Stdarg. h
>
//
To include this header file
Void
Variable (
Int
I ,...){
Int
J
=
0
;Va_list arg_ptr;
//
Step 2: Define the variable pointing to the parameter list
CTI time C ++ switch RAC Oca. com Composition
--- Restore content start ---
1. _ tmain () is a program entry point function provided by Microsoft operating system (Windows) for automatic conversion of Unicode and ANSI character sets.
First, this _
Int printf (const char * format,...); Outputs Information to the default standard output device according to the specified format. The returned value is the number of printed characters, excluding the Terminator. For example, if printf ("1234") is
Address: http://google-perftools.googlecode.com/svn/trunk/doc/cpuprofile.html
The CPU profiler usage process consists of three steps: connecting to the application, running the code, and analyzing the output result.
1. link the library into the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.